02. Experimenting with the Code (OPTIONAL)
Experimenting with the Code (OPTIONAL)
Experimenting with the Code (OPTIONAL)
These are optional steps you can take If you’re interested in experimenting with the code in parts 1 and 2 of the practice set. You’ll need to do the following steps in your Practice Set 2
project that you just created.
Step 1 : Add the Display Code to Java
Delete everything in MainActivity.java
. Then copy over all of the code in this gist into the MainActivity.java
file.
Step 2 : Add the Display Code to XML
Delete everything in activity_main.xml
. Then copy over all of the code in this gist into the activity_main.xml
file.
Step 3 : How to use your new code
At this point, you’re set to experiment with the code in parts 1 and 2 of this practice set. You'll find the code in the Instructor Notes.
The code will always have this heading and look like this example below:
Code
Declaration and initialization one
String-name = "Katherine";
Declaration and initialization two
String "name" = "Kunal";
Declaration and initialization three
String name on profile = "Lyla";
or be linked in a gist like this one
Copy the code below the comment in onCreate
that says:
Then you can run your app to see what the does.
You can practice this now. Add the following code after the comment in onCreate
:
display1("This is Box 1."); display2("And this is Box 2."); display3("And look! Box 3!");
Which should display:
This is Box 1. And this is Box 2. "And look! Box 3!"
Happy coding!